package com.cdut.hwadeefsc.controller;

import com.cdut.hwadeefsc.entity.attendance;
import com.cdut.hwadeefsc.service.attendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/api/students")
public class attendanceController {

    @Autowired
    private attendanceService attendanceService;

    // 查看学生考勤
    @GetMapping("/{studentId}/attendance")
    public ResponseEntity<List<attendance>> getStudentAttendance(
            @PathVariable Integer studentId){
        try {
            List<attendance> attendance;
            attendance = attendanceService.getStudentAttendance(studentId);
            return ResponseEntity.ok(attendance);
        } catch (Exception e) {
            return ResponseEntity.internalServerError().build();
        }
    }
}
